<template>
	<div class="userBg">
		<div class="container">
			<div class="lists">
				<div class="item" v-for="(item,index) in dkList" :key="index">
					<div class="imgBox">
						<image :src="item.img" @click="previewImg(item.img)"></image>
					</div>
					<div class="text">
						<h3>{{item.time}}</h3>
					</div>
				</div>
			</div>
			
			<div class="loadBox" v-if="searchLoading">
				<u-loading-icon size="36" mode="circle" :vertical="true" color="red" text="加载中..." textSize="20"></u-loading-icon>
			</div>
			
		</div>
	</div>
</template>

<script>
	import {
		mapActions
	} from 'vuex';
	const db = wx.cloud.database()
	export default {
		data() {
			return {
				tphone:"",
				userinfo:"",
				searchLoading:true,
				dkList: []
			}
		},
		onLoad(options) {
			this.tphone = options.phone
			this.getuserinfo()
		},
		onReady() {
			
		},
		computed: {
			userphone() {
				return this.$store.getters.userphone ? this.$store.getters.userphone : '';
			},
		},
		created() {
			let that = this;
		},
		mounted() {
			let that = this 
			
		},
		watch: {
			
		},
		methods: {
			...mapActions(['LogSetPhone','LogSetOpenid']),
			getuserinfo() {
				let that = this
				db.collection('nbhd_tiku_students').where({
					phone: that.tphone
				}).get({
					success: res => {
						
						if(res.data.length > 0){
							that.userinfo = res.data[0]
							that.getList(0)
						}
						
					}
				})
			},
			getList(page){
				let that = this
				wx.cloud.callFunction({
					name: 'get_page_phone',
					data: {
						fncname: '24sk_daka_info',
						phone: that.tphone,
						page: page,
						limit: 100
					},
					complete: res => {
						console.log(res)
						if(res.result.data.length > 0){
							that.dkList = that.dkList.concat(res.result.data)
							let p = page + 1
							that.getList(p)
						}else{
							that.searchLoading = false
							that.dkList.reverse()
						}
						
					}
				})
			},
			previewImg(link){
				wx.previewImage({
					current: link,  // 当前显示图片的链接
					urls: [link]  // 需要预览的图片链接列表
				})
			}
		},
		components: {
			
		}
	};
</script>

<style scoped>
	@import url(./index.css);
</style>